package drds.configuration.mvc.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WebApp {
    // 设置编码
    static final String Utf_8 = "utf-8";

    public static void setCharacterEncoding(HttpServletRequest request, HttpServletResponse response) {
        try {
            request.setCharacterEncoding(Utf_8);
            response.setCharacterEncoding(Utf_8);
        } catch (Exception e) {
            throw new RuntimeException("系统Jsp编码设置失败");
        }

    }

    /**
     * 返回http://www.baidu.com:8080
     */
    public static String getWebRootPath(HttpServletRequest request) {
        String path = request.getContextPath();
        StringBuilder __ROOT_PATH__ = new StringBuilder();
        __ROOT_PATH__.append(request.getScheme()).append("://").append(request.getServerName()).append(":").append(request.getServerPort()).append(path);
        return __ROOT_PATH__.toString();

    }

    /**
     * 返回http://www.baidu.com:8080/__PUBLIC__
     */
    public static String getPublicPath(HttpServletRequest request) {
        String __PUBLIC__ = getWebRootPath(request) + "/__PUBLIC__";// 资源文件
        return __PUBLIC__;

    }


    public static void main(String[] s) {
        System.out.print("PRIMARY_KEY".toLowerCase());
    }
}
